<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
	protected function _initAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'Default_',
            'basePath'  => dirname(__FILE__),
        ));
        return $autoloader;
    }
    
    protected function _initView()
    {	
		$view = new Zend_View(); 
		Zend_Dojo::enableView($view);
		$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
		$viewRenderer->setView($view);

		$options = $this->getOption('view');
		$view->headMeta()
			->appendHttpEquiv('Content-Type', $options['content-type'])
			->appendHttpEquiv('Content-Language', $options['content-language']); //'ru-RU'
		$view->headTitle($options['title']);
		$view->doctype($options['doctype']);
        $view->addHelperPath("ZendX/JQuery/View/Helper", "ZendX_JQuery_View_Helper");
		return $view;
    }
	
	protected function _initRoute()
	{

	    $routePlacesShowPlace = new Zend_Controller_Router_Route_Regex(
	        'places/([a-zA-Z0-9_]+)-([0-9]+)/?',
	        array(
	            'controller'	=> 'places',
	            'action'	    => 'showPlace'	            
	        ),
	        array(
	            '1'	=> 'placeLatName',
	            '2'	=> 'placeId'
	        )
	    );
		
		$ctrl=Zend_Controller_Front::getInstance();
		$router = $ctrl->getRouter();
		$router	-> addRoute('PlacesShowPlace', $routePlacesShowPlace)
			  //->addRoute('')
		;
	}
	
	protected function _initDatabase()
	{
		$this->bootstrap('db');
		$db = $this->getResource('db');
		Zend_Registry::set('db', $db);
	}
	
	protected function _initParams()
	{
		//Zend_Registry::set('userId', 1);
	}
	
/**
	 * Инициализирует static salt 
	 */
    protected function _initStaticSalt()
    {
        $staticSalt = $this->getOption('staticsalt');
        Zend_Registry::set('staticSalt', $staticSalt['salt']);
    }
}